package com.xyht.sca_s.student_manage_system.modules.patrol.controller;


import com.xyht.sca_s.student_manage_system.common.commonReturn.ResponseResult;
import com.xyht.sca_s.student_manage_system.common.desEncodeAndDecode.annotation.SecretBody;
import com.xyht.sca_s.student_manage_system.modules.patrol.service.SmsPatrolImageService;
import com.xyht.sca_s.student_manage_system.modules.patrol.entity.vo.SmsPatrolImageVO;
import io.swagger.annotations.ApiOperation;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;
import org.springframework.web.multipart.MultipartFile;

import javax.servlet.http.HttpServletResponse;

/**
 * <p>
 *  前端控制器
 * </p>
 *
 * @author XYHT
 * @since 2023-04-12
 */
@RestController
@SecretBody
@RequestMapping("/patrolImage/smsPatrolImage")
public class SmsPatrolImageController {
    @Autowired
    SmsPatrolImageService smsPatrolImageService;
    @ApiOperation("巡查图片新增")
    @PostMapping("/patrolImageAdd")
    public ResponseResult patrolImageAdd(@RequestParam("file") MultipartFile file, @RequestParam("picType") String picType) {
        return smsPatrolImageService.patrolImageAdd(file,picType );
    }
    @ApiOperation("删除图片")
    @DeleteMapping("/deletePatrolImage")
    public ResponseResult deleteById(@RequestBody SmsPatrolImageVO smsPatrolImage) {
        return smsPatrolImageService.deleteById(smsPatrolImage);
    }
    @ApiOperation("修改图片")
    @PostMapping("/updatePatrolImage")
    public ResponseResult update(@RequestBody SmsPatrolImageVO smsPatrolImage) {
        return smsPatrolImageService.update(smsPatrolImage);
    }

    @ApiOperation("查询图片")
    @GetMapping("/selectPatrolImage")
    public ResponseResult selectPatrolImage(@RequestParam String  id) {
        return smsPatrolImageService.selectPatrolImage(id);
    }

    @ApiOperation("根据类别查询图片")
    @GetMapping("/selectPatrolImageByPicType")
    public ResponseResult selectPatrolImageByPicType(
                                                     @RequestParam(value = "pic_type", required = false) String pic_type,
                                                     @RequestParam(value = "pageSize", defaultValue = "10") Integer pageSize,
                                                     @RequestParam(value = "pageNum", defaultValue = "1") Integer pageNum,
                                                     @RequestParam(value = "bg_date", required = false) String bg_date,
                                                     @RequestParam(value = "end_date", required = false) String end_date) {
        return smsPatrolImageService.selectPatrolImageByPicType(pic_type,pageSize,pageNum,bg_date,end_date);
    }

    @GetMapping("/showImage/{id}")
    public String showImage(@PathVariable("id") int id){
        return smsPatrolImageService.showImage(id);
    }

    @GetMapping("/download/{id}")
    public ResponseResult downloadFileManagement(@PathVariable("id") String id, HttpServletResponse response){
        return smsPatrolImageService.downloadFileManagement(id,response);
    }
}

